package xyz.kongbai121.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.kongbai121.demo.domain.RespBean;
import xyz.kongbai121.demo.service.ICommentService;
import xyz.kongbai121.demo.util.SensitiveWord;
import xyz.kongbai121.demo.util.UserPowerException;


/**
 * 文章评论处理控制器
 *
 * @author 空白
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private ICommentService service;

    @RequestMapping("/deliver")
    public RespBean commentDeliver(String content, Long articleId,Long commentId, Long toUserId, String token) {
        //敏感字符处理
        String securityContent = SensitiveWord.getSensitiveWord().filterInfo(content);
        String msg = service.save(securityContent, articleId, commentId, toUserId, token);
        return new RespBean(true, msg);
    }

    @RequestMapping("/delete")
    public RespBean commentDelete(Long id, String token) {
        String msg = service.delete(id, token);
        return new RespBean(true, msg);
    }

    @RequestMapping("/list")
    public RespBean list(Long articleId) {
        return new RespBean(true, service.list(articleId));
    }

}
